﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class zoushitu_dlt_dlt_dqzs : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected int jinqiCount = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }
    protected void bindData(int maxValue)
    {

        if (maxValue > 2000)
        {
            int Count = 0;
            DateTime dt = DateTime.Now;
            string currentYear = dt.Year.ToString();
            if (currentYear == maxValue.ToString())//当前年份
            {
                arlist = BLL.LotteryAnnouncement.GetListByShuangseDSqi1(0, maxValue, 2, 1, out Count);

            }
            else//其他年份
            {
                string sqlstr = "SELECT  * FROM LotteryAnnouncement WHERE LotteryType = 2 and DATEPART(YEAR, openTime)= '" + maxValue + "' and  LotteryQS%2=1 ORDER BY id asc";
                arlist = BLL.LotteryAnnouncement.GetList(sqlstr);
            }
         
            //sqlstr = "SELECT  * FROM LotteryAnnouncement WHERE LotteryType = 2 and DATEPART(YEAR, openTime)= DATEPART(YEAR, GETDATE())  and  LotteryQS%2=1 ORDER BY id asc";
        }
        else
        {
            string sqlstr = "select * from (SELECT top(" + maxValue + ") * FROM LotteryAnnouncement WHERE (LotteryType = 2 and DATEPART(YEAR, openTime) = DATEPART(YEAR, GETDATE())) and  LotteryQS%2=1 ORDER BY id DESC) a ORDER BY id asc";
            arlist = BLL.LotteryAnnouncement.GetList(sqlstr);
        }

        if (arlist != null)
        {
            for (int i = 0; i < arlist.Count; i++)
            {
                //重号
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(0, int.Parse(redBall[m]));

                }
                string[] blueBall = arlist[i].LotteryNo.Split('+')[1].Split(',');
                for (int m = 0; m < blueBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(1, int.Parse(blueBall[m]));

                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[49];
    /// <summary>
    /// 计算红篮球的出现个数
    /// </summary>
    /// <param name="type">0 红球 1 蓝球</param>
    /// <param name="data">对应球的号码</param>
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 47; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            if (type == 1)
            {
                if (data == (i + 1 - 35))
                {
                    TiaoxingDT[i] += 1;
                }
            }
        }
    }
}